package com.drg.center.controller;

import com.drg.center.entity.param.SysPositionEditDTO;
import com.drg.center.entity.param.SysPositionListDTO;
import com.drg.center.entity.result.SysPositionExtVO;
import com.drg.center.entity.result.SysPositionVO;
import com.guaike.core.entity.result.PageEntity;
import com.guaike.core.entity.result.Result;
import com.drg.center.service.SysPositionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @Author: zhangxilin
 * @Date: 2024/5/14
 */

@RestController
@RequestMapping("/position")
@Api(tags = "系统-岗位接口组")
public class SysPositionController {

    @Autowired
    private SysPositionService sysPositionService;

    @PostMapping("/edit")
    @ApiOperation(value = "编辑")
    public Result<Boolean> edit(@Valid @RequestBody SysPositionEditDTO param){
        return sysPositionService.edit(param);
    }

    @GetMapping("/detail")
    @ApiOperation(value = "详情")
    public Result<SysPositionExtVO> detail(@ApiParam("ID") @RequestParam("id") Long id){
        return sysPositionService.detail(id);
    }

    @GetMapping("/findPage")
    @ApiOperation(value = "列表")
    public Result<PageEntity<SysPositionVO>> findPage(@Valid SysPositionListDTO param){
        return sysPositionService.findPage(param);
    }

    @GetMapping("/all")
    @ApiOperation(value = "所有岗位")
    public Result<List<SysPositionVO>> all(){
        return sysPositionService.all();
    }


    @DeleteMapping("/delete")
    @ApiOperation(value = "删除")
    public Result<Boolean> delete(@ApiParam("ID") @RequestParam("id") Long id){
        return sysPositionService.delete(id);
    }


}
